package top.didi.study.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.didi.study.base.PageBean;
import top.didi.study.base.R;
import top.didi.study.entity.TbCpu;
import top.didi.study.service.TbCpuService;
import top.didi.study.vo.PageVO;

@RestController
@RequestMapping("/tbCpu")
@RequiredArgsConstructor
public class TbCpuController {
    public final TbCpuService tbCpuService;

    @PostMapping("")
    public R<String> insert(@RequestBody TbCpu tbCpu){
        return tbCpuService.insert(tbCpu);
    }

    @PutMapping("")
    public R<String> update(@RequestBody TbCpu tbCpu) { return tbCpuService.update(tbCpu);}

    @DeleteMapping("/{id}")
    public R<String> delete(@PathVariable("id") Integer id) { return tbCpuService.delete(id);}

    @GetMapping("/{id}")
    public R<TbCpu> queryById(@PathVariable("id") Integer id) { return tbCpuService.queryById(id);}

    @GetMapping("/{pn}/{ps}")
    public R<PageVO<TbCpu>> queryPage(@PathVariable("pn") Long pageNumber,@PathVariable("ps") Long pageSize,TbCpu tbCpu) {
        return tbCpuService.queryPage(PageBean.instance(pageNumber,pageSize),tbCpu);
    }

}
